#pragma once
#include "QD3D/QD3DResourcePack.h"
#include "QD3D/QD3DUtils.h"
#include <d3d11.h>
#include <QVector>
#include <glm/glm.hpp>

class SortPrimitive
{
public:
	static const UINT TRANSPOSE_BLOCK_SIZE = 32;
// 	CONST_STRUCT_BEGIN(SortConstVars)
// 		UINT groupNum;
// 		UINT minLevelSize;
// 		UINT maxLevelSize;
// 		UINT extLevelMask;
// 		UINT useExtLevelMask;
// 	CONST_STRUCT_END

	CONST_STRUCT_BEGIN(SortConstVars)
		unsigned int g_iLevel;
		unsigned int g_iLevelMask;
		unsigned int g_iWidth;
		unsigned int g_iHeight;
		void setData (unsigned int iLevel, unsigned int iLevelMask,
				unsigned int iWidth, unsigned int iHeight)
		{
			g_iLevel = iLevel;
			g_iLevelMask = iLevelMask;
			g_iWidth = iWidth;
			g_iHeight = iHeight;
		}
	CONST_STRUCT_END

	SortPrimitive (glm::uvec2 bufSize, QD3DResourcePack *pDataPack,
			UINT structSize, const std::string &structBufType);
	~SortPrimitive ();

	void run ();

private:
	std::string _structBufType;

	UINT _bufSize;
	UINT _groupSize;
	UINT _groupNum;

	ID3D11Buffer *_p_dataSizeDxConstBuf;
	QD3DResourcePack *_rp_dataPack;
	QD3DResourcePack *_p_tempPack;

	ID3D11ComputeShader *_p_sortCS;
	ID3D11ComputeShader *_p_transposeCS;

};